<?php


	$lp_root_path='../';
	$general_root_path = '../../';

	define('INSIDE', true);
	include($general_root_path . 'extension.inc');
	include($general_root_path . 'common.'.$phpEx);
include_once($lp_root_path. 'classes/templates.class.'.$phpEx);
include_once($lp_root_path. 'procedures.class.'.$phpEx);
include_once($lp_root_path. 'classes/json_data_classes.'.$phpEx);

$dentro=check_user();


$nick = $_SESSION['nick'];
$pass = $_SESSION['pass'];

$result = new json_request();

/*
ERROR LIST:

-1		->	No session
-2		->	No request data, missing "jsondata" parameter
-3		->	Type not implemented
-4		->	Operation not implemented
-5		->	Exception

*/

if(!$dentro)
{
	$result->error=1;
	$result->error_number=-1;
	echo "no_session";
}
else
{
	/*if($jsonraw==null)
	{
		$result->error=1;
		$result->error_number=-2;
		echo "bad_request";
	}
	else
	{*/
		/*$jsonraw = str_replace('\"','"',$jsonraw);
		$request = new json_request();
		$request->load(json_decode($jsonraw));*/

		
		$sp = new procedures();

		try
		{
			$row = $sp->sp_users_getUserSimple($nick,$pass);
							
			$userdata = new json_userData();
			$userdata->nick = $row[0]["nick"];
			$userdata->maxBuild = $row[0]["maxBuild"];
			$userdata->maxResearch = $row[0]["maxResearch"];
			$userdata->maxFleet = $row[0]["maxFleet"];
			$userdata->totalPlanets = $row[0]["totalPlanets"];
			$userdata->maxPlanets = $row[0]["maxPlanets"];							
		}
		catch (exception $e)
		{
			die($e->getMessage());
		}
	/*}*/
}

echo $lang['nick'].'<span id="user_nick" class="data">'.$userdata->nick.'</span>';
echo $lang['nick'].'<span id="user_maxBuild" class="data">'.$userdata->maxBuild.'</span>';
echo $lang['nick'].'<span id="user_maxResearch" class="data">'.$userdata->maxResearch.'</span>';
echo $lang['nick'].'<span id="user_maxFleet" class="data">'.$userdata->maxFleet.'</span>';
echo $lang['nick'].'<span id="user_totalPlanets" class="data">'.$userdata->totalPlanets.'</span>';
echo $lang['nick'].'<span id="user_maxPlanets" class="data">'.$userdata->maxPlanets.'</span>';

?>
